const defaultState = {
    menus:[],
    menusSelected: {},
    insertType: ""
};

export const homeActionsType = {
    changeMenus: "changeMenus",
    changeMenusSelected: "changeMenusSelected",
    changeInsertType: "changeInsertType",
}

export const homeActions = {
    changeMenus(action) {
        return Object.assign({type: homeActionsType.changeMenus}, action);
    },
    changeMenusSelected(action) {
        return Object.assign({type: homeActionsType.changeMenusSelected}, action);
    },
    changeInsertType(action) {
        return Object.assign({type: homeActionsType.changeInsertType}, action);
    },
}

export default (state = defaultState, action) => {
    switch (action.type) {
        case homeActionsType.changeMenusSelected:
            return Object.assign({}, state, {
                menusSelected: action.menusSelected
            })
        case homeActionsType.changeMenus:
            return Object.assign({}, state, {
                menus: action.menus
            })
        case homeActionsType.changeInsertType:
            return Object.assign({}, state, {
                insertType: action.insertType
            })
        default:
            return state;
    }
};
